package br.com.srv.service;

import java.util.List;
import java.util.Map;

import HTTPClient.HTTPConnection;
import br.com.srv.util.ArenaHelper;

public class GoogleEarthService extends ArenaBaseService {
	/**
	 * Construtor que cria um service sem um HTTPConnection.
	 */
	public GoogleEarthService() {
		this(null);
	}
	/**
	 * Construtor que cria um service com um HTTPConnection.
	 * 
	 * @param dataSource
	 */
	public GoogleEarthService(HTTPConnection connection) {
		super(connection);
	}
	
	public List consultaMapLastDataRead(Map params) throws Exception {
		StringBuffer urlString = new StringBuffer(ArenaHelper.XML_READER);
		urlString.append("<FILTER>");
		urlString.append("<CLIENT_ID>" + params.get("client_id").toString() + "</CLIENT_ID>");	
		urlString.append("<LIMIT>");
		urlString.append("<QUANT>100</QUANT>");
		urlString.append("<OFFSET>0</OFFSET>");
		urlString.append("</LIMIT>");
		urlString.append("<SHOW_FIELDS>");
		urlString.append("<ID>1</ID>");
		urlString.append("<DESC>1</DESC>");
		urlString.append("<NEAR_DESC>1</NEAR_DESC>");
		urlString.append("<DATE_TIME>1</DATE_TIME>");
		urlString.append("<Y>1</Y>");
		urlString.append("<X>1</X>");
		urlString.append("<DIR>1</DIR>");
		urlString.append("<VEL>1</VEL>");
		urlString.append("<IGNITION>1</IGNITION>");
		urlString.append("<VEL_EXCESS>1</VEL_EXCESS>");
		urlString.append("<IN1>1</IN1>");
		urlString.append("<IN2>1</IN2>");
		urlString.append("<IN3>1</IN3>");
		urlString.append("<IN4>1</IN4>");
		urlString.append("<MICROPHONE>1</MICROPHONE>");
		urlString.append("<SPEAKER>1</SPEAKER>");
		urlString.append("<OUT1>1</OUT1>");
		urlString.append("<OUT2>1</OUT2>");
		urlString.append("<OUT3>1</OUT3>");
		urlString.append("<OUT4>1</OUT4>");
		urlString.append("<IN_REF>1</IN_REF>");
		urlString.append("<ODOMETER>1</ODOMETER>");
		urlString.append("<HOURMETER>1</HOURMETER>");
		urlString.append("<VOLTAGE>1</VOLTAGE>");
		urlString.append("<TEMPERATURE>1</TEMPERATURE>");
		urlString.append("<COUNT1>1</COUNT1>");
		urlString.append("<COUNT2>1</COUNT2>");
		urlString.append("<COUNT3>1</COUNT3>");
		urlString.append("</SHOW_FIELDS>");
		urlString.append("</FILTER>");
		
		String xml = queryArenaMethod(ArenaHelper.WEB_SERVICE_MAPLASTDATAREAD, urlString);

		List result = parseList(xml, "/VEHICLES", "VEHICLE");
		
		return result;
	}

}
